#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;
bool backstr(string s)
{
    int left = 0;
    int right = s.size()-1;
    while (left < right)
    {
        if (s[left] == s[right])
        {
            left++;
            right--;
        }
        else {
            return false;
        }
    }
    return true;
}
int main() {
    string s;
    char c;
    int count = 0;
    cin >> s >> c;
    for (int i = 0; i <= s.size(); i++)
    {
        string tmp = s;
        tmp.insert(tmp.begin() + i, c);
        if (backstr(tmp) == 1)
            count++;
    }
    cout << count << endl;
}